-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL - full text functions verifier tests refactor #128775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL - full text functions verifier tests refactor #128775
Conversation
| plan, | ||
| condition, | ||
| Term.class, | ||
| FullTextFunction.class, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified this to just run on all FullTextFunctions
| return fields.stream() | ||
| .map( | ||
| (Expression field) -> isNotNull(field, sourceText(), FIRST).and( | ||
| (Expression field) -> isNotNull(field, sourceText(), SECOND).and( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed a bug in MultiMatch when refactoring the tests
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
…unctions-verifier-tests-refactor' into non-issue/esql-full-text-functions-verifier-tests-refactor
| + " or first_name is not null) or (length(first_name) > 12 and match(last_name, \"Smith\"))" | ||
| ); | ||
| query("from test | where " + functionInvocation + " or (last_name is not null and first_name is null)"); | ||
| if ("KQL".equals(functionName) || "QSTR".equals(functionName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this test need to be limited to just KQL and QSTR? I'd expect the same error for match too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's limited to QSTR / KQL, as these do not include a field. MATCH et al would fail on not having an actual field to look into, as this test case uses ROW to generate a column instead.
| "1:45: [QSTR] function cannot be used after RENAME", | ||
| error("from test | rename last_name as full_name | where qstr(\"Anna\")") | ||
| ); | ||
| public void testNonFieldBasedFullTextFunctionsNotAllowedAfterCommands(String functionName, String functionInvocation) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should these helper methods be private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Done in ac0982a
| "1:48: [MATCH] function cannot operate on [text::keyword], which is not a field from an index mapping", | ||
| error("row n = null | eval text = n + 5 | where match(text::keyword, \"Anna\")") | ||
| ); | ||
| public void testQueryStringFunctionsNotAllowedAfterCommands() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we group this one with the KQL equivalent in one function? so we keep the same pattern that we have in the rest of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done in ac0982a
| assertEquals( | ||
| "1:67: [MATCH] function cannot operate on [initial], which is not a field from an index mapping", | ||
| error("from test | eval initial = substring(first_name, 1) | where match(initial, \"A\")") | ||
| public void testFieldBasedWithNonIndexedColumn(String functionName, String functionInvocation, String functionType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have a different name pattern for these helper functions e.g. checkFieldBasedWithNonIndexedColumn.
we have other functions like this e.g. checkFullTextFunctionsOnlyAllowedInWhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I have been inconsistent here. Done in ac0982a
…unctions-verifier-tests-refactor' into non-issue/esql-full-text-functions-verifier-tests-refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review @ioanatia ! I've fixed the inconsistent naming you found.
| + " or first_name is not null) or (length(first_name) > 12 and match(last_name, \"Smith\"))" | ||
| ); | ||
| query("from test | where " + functionInvocation + " or (last_name is not null and first_name is null)"); | ||
| if ("KQL".equals(functionName) || "QSTR".equals(functionName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's limited to QSTR / KQL, as these do not include a field. MATCH et al would fail on not having an actual field to look into, as this test case uses ROW to generate a column instead.
| "1:45: [QSTR] function cannot be used after RENAME", | ||
| error("from test | rename last_name as full_name | where qstr(\"Anna\")") | ||
| ); | ||
| public void testNonFieldBasedFullTextFunctionsNotAllowedAfterCommands(String functionName, String functionInvocation) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Done in ac0982a
| "1:48: [MATCH] function cannot operate on [text::keyword], which is not a field from an index mapping", | ||
| error("row n = null | eval text = n + 5 | where match(text::keyword, \"Anna\")") | ||
| ); | ||
| public void testQueryStringFunctionsNotAllowedAfterCommands() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done in ac0982a
| assertEquals( | ||
| "1:67: [MATCH] function cannot operate on [initial], which is not a field from an index mapping", | ||
| error("from test | eval initial = substring(first_name, 1) | where match(initial, \"A\")") | ||
| public void testFieldBasedWithNonIndexedColumn(String functionName, String functionInvocation, String functionType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I have been inconsistent here. Done in ac0982a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this new mapping, as I found easier when working on KNN to have a separate mapping for full text functions than to modify the default mapping - which impacted a lot of other tests.
This way we can be the owners of this mapping in case we want to add later for example sparse_vector field types, and not impact other test cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "1:36: [MultiMatch] function is only supported in WHERE and STATS commands\n" | ||
| + "line 1:55: [MultiMatch] function cannot operate on [title], which is not a field from an index mapping", | ||
| error("row title = \"brown fox\" | eval x = multi_match(\"fox\", title)") | ||
| private void testFullTextFunctionsConstantQuery(String functionInvocation, String argOrdinal) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be checkFullTextFunctionsConstantQuery 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - did that on 2818298
| assertEquals( | ||
| "1:19: first argument of [multi_match(null, first_name)] cannot be null, received [null]", | ||
| error("from test | where multi_match(null, first_name)") | ||
| private void testFullTextFunctionNullArgs(String functionInvocation, String argOrdinal) throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be checkFullTextFunctionNullArgs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch - did that on 2818298
💔 Backport failed
You can use sqren/backport to manually backport by running |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit dc3d515) # Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextFunction.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/MultiMatch.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
(cherry picked from commit dc3d515) # Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextFunction.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/MultiMatch.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java
Refactors tests on VerifierTests to include all full text functions